<template>
	<view>
		<view class="aaa">
			<image src="../../static/img/logo.png" class="login_logo_img">
				<view class="aaa_text">
					欢迎来到点点滴滴
				</view>
		</view>
		<view class="form_bc">
			<u--input placeholder="请输入账号" border="surround" v-model="ipone"
				style="background-color: #f1f1f1;width: 75%;border-radius: 20px; margin: 0 auto;height: 35px;"></u--input>
			<u--input placeholder="请输入密码" border="surround" v-model="password"
				style="background-color: #f1f1f1;width: 75%;border-radius: 20px; margin: 20px auto;height: 35px;"></u--input>
			<view class="input_flex">
				<u--input placeholder="请输入内容" border="surround" v-model="code"
					style="background-color: #f1f1f1;width: 75%;border-radius: 20px; margin: 0 auto;height: 35px;"></u--input>
				<view class="count_styles" @click="qiehuan">
					<img :src="urls?urls:propValue " mode="widthFix" class="count_style_img"></img>
				</view>
			</view>
			<view class="dl_button" @click="dl_button">
				立即登录
			</view>
			<view class="vie">
				<view class="vie_zh" @click="yanzhengm">验证码登录</view>
				<view>
					<text class="vie_zh">还没有账号？</text>
					<text class="vie_zc" @click="verification">去注册</text>
				</view>
			</view>
			<view class="checked_button">
				<u-checkbox-group>
					<u-checkbox @change="checkboxChange"></u-checkbox>
					<text class="vie_zh">勾选表示同意</text>
					<text class="vie_zc">《服务协议》</text>
					<text class="vie_zh">与</text>
					<text class="vie_zc">《隐私政策》</text>
				</u-checkbox-group>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				ipone: '',
				password: '',
				code: '',
				count: '',
				checked: '',
				urls: '',
				uuid: '',
			}
		},
		props: {
			// 定义 prop，并指定其类型  
			propValue: {
				type: String,
				required: true, // 如果需要，可以设置为必传  
				default: '' // 可以设置一个默认值  
			}
		},
		onLoad() {
			this.yanzheng()
		},
		methods: {
			yanzhengm() {
				uni.navigateTo({
					url: '/pages/login/login'
				})
			},
			qiehuan() {
				this.yanzheng()
			},
			yanzheng() {
				this.$ajax('get', 'code').then((res) => {
					this.urls = 'data:image/gif;base64,' + res.data.img
					this.uuid = res.data.uuid
				})
			},
			dl_button() {
				if (this.checked == true) {
					if (this.ipone != '' && this.password != '' && this.code != '') {
						this.$ajax('post', 'auth/appLogin', {
							username: this.ipone,
							password: this.password,
							code: this.code,
							uuid: this.uuid
						}).then(async (res) => {
							// 17808093134
							if (res.code == 200) {
								await uni.setStorageSync('key', res.data.access_token);
								// setTimeout(() => {
								//     this.$router.go(0)
								// }, 500)
								this.$tokenKey()
							} else {
								+ -
								this.$api.msg(res.message)
							}
						})
					} else {
						uni.showToast({
							title: '请完整填写表单在进行登录',
							icon: 'none'
						});
					}
				} else {
					uni.showToast({
						title: '请先勾选底部协议',
						icon: 'none'
					});
				}
			},
			verification() {
				uni.navigateTo({
					url: './verification'
				})
			},
			checkboxChange(n) {
				this.checked = n
			}
		}
	}
</script>

<style>
	page {
		background-image: url('../../static/img/bj.jpg');
		background-size: cover;
	}

	.count_styles {
		width: 100px;
		height: 36px;
		color: #fff;
		text-align: center;
		line-height: 25px;
		margin-left: 20px;
		font-size: 14px;
	}

	.count_style_img {
		width: 100%;
		height: 100%;
		object-fit: cover;
	}

	.input_flex {
		width: 80%;
		display: flex;
		align-items: center;
		margin: 20px auto;
	}

	.checked_button {
		position: fixed;
		bottom: 5%;
		left: 10%;
	}

	.vie {
		display: flex;
		justify-content: space-around;
	}

	.vie_zh {
		color: #a1a4a3;
	}

	.vie_zc {
		color: #56a5fa;
	}

	.dl_button {
		width: 80%;
		margin: 26px auto;
		background-color: #268dfe;
		font-size: 18px;
		color: #fff;
		text-align: center;
		height: 50px;
		line-height: 50px;
		border-radius: 30px;
	}



	.form_bc {
		width: 100%;
		margin-top: 50px;
	}

	.aaa {
		padding-top: 80px;
		height: 240px;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.aaa_text {
		margin-top: 35px;
		font-size: 22px;
		font-weight: 500;
	}

	.login_logo_img {
		width: 100px;
		height: 100px;
	}

	.uni-input-input {
		background-color: 'red' !important;
	}
</style>